﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using CodeArt.SharePoint.CamlQuery;
using System.Data;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            TestUserQuery();

            Console.ReadLine();
        }


      
        public static void TestUserQuery()
        {
            SPSite site = new SPSite("http://moss2007:82");
            SPWeb web = site.RootWeb;

            SPList list = web.Lists["Tasks"];

            int year = DateTime.Now.Year;

            DateTime yearBegin = new DateTime(year, 1, 1);
            DateTime yearEnd = new DateTime(year + 1, 1, 1);

            TypedQueryField<DateTime> createDtField = new TypedQueryField<DateTime>("BeginTime");

            TypedQueryField<SPUser> userField = new TypedQueryField<SPUser>("Author");

            TypedQueryField<SPUser> AssignedTo = new TypedQueryField<SPUser>("AssignedTo");

            //var UserField1 = new TypedQueryField<SPUser>("用户1", false);

            var UserField2 = new LookupQueryField("负责人", false);

            QueryField dayCountField = new QueryField("TotalDayCount");

            SPUser user = web.SiteUsers["MOSS2007\\user2"];

            SPFolder folder = list.RootFolder.SubFolders["fffff"];

            //已经休假数据
            DataTable vacationData =
                ListQuery//.Select(UserField2)
                .From(list, folder, QueryScope.RecursiveAll)
                .Where(UserField2 == user.ID)
                .GetDataTable();


            Console.WriteLine(vacationData.Rows.Count);

        }
    }
}
